﻿using System;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] arr;
            arr = new int[20];
            Random rand = new Random();
            //使用随机数来模拟数组中元素
            for(int i = 0; i < arr.Length; i++)
            {
                arr[i] = rand.Next(1, 1000);
            }
            int max, min, avg, sum;
            max = arr[0];
            min = arr[0];
            sum = 0;
            foreach(int item in arr)
            {
                if (item > max)
                    max = item;
                else if (item < min)
                    min = item;
                sum += item;
            }
            avg = sum / arr.Length;//忽略小数值

            Console.WriteLine("数组arr各项特征数值为：最大值{0},最小值{1},总和是{2},平均值是{3}", max, min, sum, avg); ;
        }
    }
}
